//
//  Modifiers.swift
//  DesignCodeDemo
//
//  Created by yuchuntao on 2020/8/31.
//  Copyright © 2020 yuchuntao. All rights reserved.
//

import SwiftUI

struct ShadowModifer: ViewModifier {
    func body(content: Content) -> some View {
        content
            .shadow(color: Color.black.opacity(0.1), radius: 10, x: 0, y: 12)
            .shadow(color: Color.black.opacity(0.1), radius: 1, x: 0, y: 1)
    }
}

struct FontModifier: ViewModifier {
    var style: Font.TextStyle = .body
    func body(content: Content) -> some View {
        content
            .font(.system(style, design: .default))
    }
}

struct CustomFontModifier: ViewModifier {
    var size: CGFloat = 28
    func body(content: Content) -> some View {
        content
            .font(.custom("WorkSans-Bold", size: size))
    }
}

extension View {
    func shadows() -> some View {
        self.modifier(ShadowModifer())
    }
    
    func fonts(style: Font.TextStyle) -> some View {
         self.modifier(FontModifier(style: style))
    }
    
    func customFont(size: CGFloat) -> some View {
        self.modifier(CustomFontModifier(size: size))
    }
}
